<?php include "header.html"; ?> 

<body>
 
	<div class="zss-wrap">

		<div class="zss-header">
            <span class="layui-breadcrumb">
                <?= $this->get_loc($this->baseClass, "编辑"); ?>
            </span>
        </div>

		<div class="zss-nav">
			<a type="button" class="layui-btn" href="<?= U($this->baseClass, $this->getArgs()) ?>">
				<i class="layui-icon layui-icon-return"></i> 返回 
			</a>
		</div>

		<div class="zss-content">

			<div class="layui-tab layui-tab-brief">
				<ul class="layui-tab-title">
					<a><li class="layui-this">添加广告</li></a>
				</ul>
			</div>

			<div class="zss-form-box">
				<form action="<?= U($this->baseClass . '/submit', $this->getArgs()) ?>" method="post" class="layui-form">
					<div class="layui-form-item">
						<label class="layui-form-label">广告名称</label>
						<div class="layui-input-block">
							<input type="text" name="ad_name" lay-verify="required" placeholder="请输入广告名称" autocomplete="off" class="layui-input" value='<?= $row['ad_name'] ?>'>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">广告位置</label>
						<div class="layui-input-block">
							<select name="ad_position" lay-verify="required">
								<option value="">请选择位置 --- </option>                 
								<?php 
								
								foreach($global["ad_position_list"] as $position) {
								?>
								<option value="<?=$position['position_id']?>" <?php if($position['position_id'] == $row['ad_position']) {?> selected<?php }?>><?=$position['position_name']?></option>
								<?php } ?>
							</select>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">绑定分类</label>
						<div class="layui-input-block">
							<select name="ad_category">
								<option value="">请选择分类 --- </option>                 
								<?= $this->recursive_category_select(0, $row['ad_category'], ''); ?>
							</select>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">绑定内容</label>
						<div class="layui-input-block">
							<select name="ad_content_id">
								<option value="">请选择内容 --- </option>                 
								<?php

									$plist = \core\libs\db::fetchAll(
										"content, category", 
										"con_cid = category_id and category_cid = 4 order by con_hot desc, con_top desc, con_order desc, con_time desc"
									);
									
									if($plist) {
										foreach($plist as $vp) {
										?>
										<option value="<?=$vp['con_id']?>" <?php if($vp['con_id'] == $row['ad_content_id']) { ?>selected<?php }?>>【<?=$vp['con_alias']?>】<?=$vp['con_name']?></option>      
									<?php }?>
								<?php }?>
							</select>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">广告描述</label> 
						<div class="layui-input-block">
							<textarea name="ad_describe" placeholder="请输入内容" class="layui-textarea"><?= $row['ad_describe'] ?></textarea>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">广告图片</label>
						<div class="layui-input-block">
							<?php $this->get_upload_image("pic1", "ad_pic", $row['ad_pic']); ?>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">广告视频</label>
						<div class="layui-input-block">
							<?php $this->get_upload_video("video1", "ad_video", $row['ad_video']); ?>
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">发布时间</label>
						<div class="layui-input-block">
							<input type="text" name="ad_time" placeholder="" autocomplete="off" class="layui-input" value="<?= $row['ad_time'] ? date('Y-m-d H:i:s', $row['ad_time']) : date('Y-m-d H:i:s') ?>" id="input_time">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">连接</label>
						<div class="layui-input-block">
							<input type="text" name="ad_url" placeholder="" autocomplete="off" class="layui-input" value="<?= $row['ad_url'] ?>">
						</div>
					</div>

					<div class="layui-form-item" pane>
                        <label class="layui-form-label">打开方式</label>
                        <div class="layui-input-block">
                            <input type="radio" name="ad_target" value="0" title="当前窗口" <?php if($result['ad_target'] == 0) { echo 'checked'; }?>>
                            <input type="radio" name="ad_target" value="1" title="新窗口" <?php if($result['ad_target'] == 1) { echo 'checked'; }?>>    
                        </div>
                    </div>

					<div class="layui-form-item">
						<label class="layui-form-label">权重排序</label>
						<div class="layui-input-block">
							<input type="text" name="ad_order" placeholder="" autocomplete="off" class="layui-input" value="<?= $row['ad_order'] ?>">
						</div>
					</div>

					<div class="layui-form-item">
						<label class="layui-form-label">审核状态</label>
						<div class="layui-input-block">
							<input type="checkbox" value="1" name="ad_enable" lay-skin="switch" lay-text="取消|通过" <?php if($row['ad_enable'] != '0') { echo 'checked'; }?>>
						</div>
					</div>

					<div class="layui-form-item">
						<div class="layui-input-block">
						  <input type="hidden" value="<?= $global['id'] ?>" name="id" />
						  <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
						</div>
					</div>
				</form>
			</div>

		</div>
	</div>
	
	<script>
		layui.use(['element', 'form', 'laydate'], function() {
			var laydate = layui.laydate;
			//执行一个laydate实例
			laydate.render({
				elem: '#input_time' //指定元素
				,type: 'datetime'
			});
		});
	</script>
</form>  
</body>
</html>
